//Source file: D:\\test\\com\\ce\\pms\\custservice\\service\\IEventManageService.java

package com.ce.pms.custservice.service;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import junit.framework.Assert;

import com.ce.pms.DBUnitTool;
import com.ce.pms.custservice.dao.ICustServiceEventDao;
import com.ce.pms.custservice.model.CustServiceEventDO;
import com.ce.pms.custservice.vo.CustServiceEventSearchVO;
import com.ce.pms.custservice.vo.CustServiceEventVO;
import com.sitechasia.webx.core.support.Page;



/***
 * 客服事件管理接口
 * @author 高嵩
 *
 */
public class EventManageServiceImplT extends DBUnitTool {

	private ICustServiceEventDao custServiceEventDao;

	private IEventManageService eventManageService;



	private void initCustServiceEventService(){
		if(this.eventManageService == null){
			this.eventManageService = (IEventManageService)this.applicationContext.getBean("eventManageService");
		}
		if(this.custServiceEventDao ==  null){
			this.custServiceEventDao = (ICustServiceEventDao)this.applicationContext.getBean("custServiceEventDao");
		}
	}
	/* (non-Javadoc)
	 * @see com.ce.pms.DBUnitTool#setUp()
	 */
	@Override
	public void setUp() throws Exception {
		// TODO Auto-generated method stub
		super.setUp();
		initCustServiceEventService();
		Assert.assertNotNull(eventManageService);
		Assert.assertNotNull(custServiceEventDao);
	}

	/* (non-Javadoc)
	 * @see com.ce.pms.DBUnitTool#tearDown()
	 */
	@Override
	public void tearDown() throws Exception {
		// TODO Auto-generated method stub
		super.tearDown();
		eventManageService = null;
		custServiceEventDao = null;
	}

	/***
	 * 功能描述:  私有方法，设置值<br>
	 * @param custServEventVO
	 * @return
	 * Create author:高嵩 <br>
	 * Create on:2008-12-30  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private CustServiceEventVO getCustServiceEventVO(CustServiceEventVO custServEventVO){

		custServEventVO.setContact("联系人");
		custServEventVO.setEventContent("事件内容");
		custServEventVO.setValidity("001");//有效性:001有效;002待定;000无效
		custServEventVO.setCreator(new Long(1));//创建人
		//custServEventVO.setModifier(new Long(2));//修改人
		custServEventVO.setHouseKeyword(new Long(6));//房号主键

		custServEventVO.setEventRegionKeyword(new Long(2));//事件区域
		custServEventVO.setCustServEventKindKeyword(new Long(1));//事件类型
		custServEventVO.setEventNatureKeyword(new Long(1));//客户事件性质
		custServEventVO.setSeriousDegreeKeyword(new Long(1));//时间严重程度ID
		custServEventVO.setEmergencyDegreeKeyword(new Long(1));//紧急程度
		custServEventVO.setAppointment("2009-01-01");//预约时间
		return custServEventVO;
	}




   /***
    * 功能描述:  测试新建客服事件<br>
    * @param custServiceEventVO
    * @return
    * @roseuid 4924D5ED02AF
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
	//@Test
   public void testAddCustEvent(){
		CustServiceEventVO custServEventVO = new CustServiceEventVO();

		System.out.println("-----------测试新建客服事件开始-------------");

		//增加客服事件记录
		this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));

		CustServiceEventDO custServiceEventDODB = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		//增加成功
		assertEquals(custServEventVO.getKeyword(),custServiceEventDODB.getKeyword());

		//删除客服事件记录
		this.custServiceEventDao.doDeleteById(custServiceEventDODB.getKeyword());
		custServiceEventDODB = this.custServiceEventDao.findById(custServiceEventDODB.getKeyword());
		//删除成功
		Assert.assertNull(custServiceEventDODB);

		System.out.println("-----------测试新建客服事件结束-------------");
   }

   /***
    * 功能描述:  修改客服事件<br>
    * @param custServiceEventVO
    * @return CustServiceEventVO
    * @roseuid 4924F5170203
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testEditCustEvent(){

	    System.out.println("---------------------修改客服事件开始-------------------------");

	    CustServiceEventVO custServEventVO = new CustServiceEventVO();
	    System.out.println("---------------------增加一条客服事件记录-------------------------");
		this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));

		CustServiceEventDO custServiceEventDODB = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		//增加成功
		assertEquals(custServEventVO.getKeyword(),custServiceEventDODB.getKeyword());


		System.out.println("-------------------对新增客服事件进行修改------------------");
		custServEventVO.setContact("联系人修改");
		custServEventVO.setEventContent("事件内容修改");
		custServEventVO.setValidity("002");//有效性:001有效;002待定;000无效
		custServEventVO.setEventRegionKeyword(new Long(3));//事件区域
		custServEventVO.setCustServEventKindKeyword(new Long(2));//事件类型
		custServEventVO.setEventNatureKeyword(new Long(2));//客户事件性质
		custServEventVO.setEmergencyDegreeKeyword(new Long(2));//紧急程度
		custServEventVO.setAppointment("2009-02-02");//预约时间
		this.eventManageService.editCustEvent(custServEventVO);
		assertEquals(custServEventVO.getContact(),"联系人修改");
		assertEquals(custServEventVO.getValidity(),"002");
		System.out.println("-----------------修改成功-----------------");


		custServiceEventDODB = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		System.out.println("-----------------删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDODB.getKeyword());
		custServiceEventDODB = this.custServiceEventDao.findById(custServiceEventDODB.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDODB);

		System.out.println("---------------------修改客服事件结束-------------------------");
   }


   /***
    * 功能描述: 测试归档 <br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   public static final String EVENT_STATUS_ARCHIVED_CODE = "005";
   //@Test
   public void testArchivism(){

	   	System.out.println("-----------------------测试归档事件开始---------------------------");

	    CustServiceEventVO custServEventVO = new CustServiceEventVO();
	    this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
		CustServiceEventDO custServiceEventDODB = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		assertEquals(custServEventVO.getKeyword(),custServiceEventDODB.getKeyword());

		//归档操作
		this.eventManageService.archivism(custServEventVO);


		CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		//判断事件状态是否为已归档状态
		assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_ARCHIVED_CODE);
		System.out.println("----------事件已归档----------");

		System.out.println("-----------------删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDODB = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDODB);

		System.out.println("-----------------------测试归档事件END---------------------------");
   }

   /***
    * 功能描述:  测试作废客服事件<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /**
	 * 事件状态:作废
	 */
	public static final String EVENT_STATUS_CANCEL_CODE = "000";
	/**
	 * 事件状态:待归档
	 */
	public static final String EVENT_STATUS_ARCHIVING_CODE = "004";
   //@Test
   public void testSetAsideCustEvent(){

	    System.out.println("--------------------作废客服事件开始----------------------");

	    CustServiceEventVO custServEventVO = new CustServiceEventVO();
	    this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
		CustServiceEventDO custServiceEventDODB = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		assertEquals(custServEventVO.getKeyword(),custServiceEventDODB.getKeyword());

		//设置作废备注
		custServEventVO.setRemark("我要作废事件");


		//新建，待归档，无效事件可以作废
		//当新建状态时，作废事件
		this.eventManageService.setAsideCustEvent(custServEventVO);

		CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());

		assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_CANCEL_CODE);
		System.out.println("---------事件状态为新建时，作废客服事件成功------");


		System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDODB = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDODB);

		System.out.println("--------------------作废客服事件结束----------------------");
   }



   /***
    * 功能描述:  测试通知事件已提交<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /**
	 * 事件状态:已提交
	 */
   public static final String EVENT_STATUS_SUBMIT_CODE = "002";
  // @Test
   public void testNoteSubmitTask(){

	   System.out.println("---------------测试通知事件已提交开始---------------");
	   CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   assertNotNull(custServEventVO);
	   this.eventManageService.noteSubmitTask(custServEventVO.getKeyword());

	   CustServiceEventDO custServiceEventDODB = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDODB);
	   //判断事件状态是否改为已提交状态
	   assertEquals(custServiceEventDODB.getEventStatuz(), EVENT_STATUS_SUBMIT_CODE);
	   System.out.println("--------------事件状态已经改为已提交状态---------------");

	    System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDODB.getKeyword());
		custServiceEventDODB = this.custServiceEventDao.findById(custServiceEventDODB.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDODB);
   }

   /***
    * 功能描述:  测试通知新增回访登记<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
	/**
	 * 事件状态:已完成
	 */
	public static final String EVENT_STATUS_COMPLETE_CODE = "003";
	/**
	 * 回访状态:待回访
	 */
	public static final String RETURN_VISIT_STATUZ_PREPARE_CODE = "001";
	/**
	 * 回访状态:已回访
	 */
	public static final String RETURN_VISIT_STATUZ_COMPLETE_CODE = "002";
	//@Test
   public void testNoteAddReturnVisit(){

	   System.out.println("--------------------测试通知新增回访登记开始----------------------");
	   CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   assertNotNull(custServEventVO);


	   //修改事件状态与回访状态，把事件状态修改"已完成",回访状态修改为"待回访"
	   custServEventVO.setEventStatuz(EVENT_STATUS_COMPLETE_CODE);
	   custServEventVO.setReturnVisitStatuz(RETURN_VISIT_STATUZ_PREPARE_CODE);
	   this.eventManageService.editCustEvent(custServEventVO);
	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_COMPLETE_CODE);
	   assertEquals(custServiceEventDO.getReturnVisitStatuz(),RETURN_VISIT_STATUZ_PREPARE_CODE);


	   //测试通知新增回访登记
	   this.eventManageService.noteAddReturnVisit(custServEventVO.getKeyword());
	   custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDO);
	   //判断回访状态是否已改为"已回访"状态
	   assertEquals(custServiceEventDO.getReturnVisitStatuz(), RETURN_VISIT_STATUZ_COMPLETE_CODE);


	    System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDO);
   }

   /***
    * 功能描述:  测试通知阅签<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /**
	 * 阅签状态:待阅签
	 */
	public static final String REVIEWER_STATUZ_PREPARE_CODE = "001";
	/**
	 * 阅签状态:已阅签
	 */
	public static final String REVIEWER_STATUZ_COMPLETE_CODE = "002";

	//@Test
   public void testNoteAddSignReading(){
	   System.out.println("---------------------测试通知阅签开始--------------------------");
	   CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   assertNotNull(custServEventVO);


	   //修改事件状态与阅签状态，把事件状态修改"已完成",阅签状态修改为"待阅签"
	   custServEventVO.setEventStatuz(EVENT_STATUS_COMPLETE_CODE);
	   custServEventVO.setReviewerStatuz(REVIEWER_STATUZ_PREPARE_CODE);
	   //更新修改后的信息
	   this.eventManageService.editCustEvent(custServEventVO);
	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   //判断修改是否成功
	   //事件状态为已完成
	   //阅签状态为待阅签状态
	   assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_COMPLETE_CODE);
	   assertEquals(custServiceEventDO.getReviewerStatuz(),REVIEWER_STATUZ_PREPARE_CODE);


	   //测试通知新增回访登记
	   this.eventManageService.noteAddSignReading(custServEventVO.getKeyword());
	   custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDO);
	   //判断阅签状态是否已改为"已阅签"状态
	   //阅签状态为"已阅签"状态
	   assertEquals(custServiceEventDO.getReviewerStatuz(), REVIEWER_STATUZ_COMPLETE_CODE);
	   //事件状态已改为"待归档"
	   assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_ARCHIVING_CODE);


	    System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDO);

   }

   /***
    * 功能描述:  测试通知新增抽检<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /**
	 * 抽检状态:已抽检
	 */
	public static final String CHECK_STATUZ_COMPLETE_CODE = "1";
	//@Test
   public void testNoteAddCheckRecord(){

	   System.out.println("---------------------测试通知新增抽检方法开始--------------------------");
	   CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   assertNotNull(custServEventVO);
	   Assert.assertNull(custServEventVO.getCheckStatuz());

	   //测试通知新增抽检
	   this.eventManageService.noteAddCheckRecord(custServEventVO.getKeyword());
	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDO);
	   //判断抽检状态是否已改为"已抽检"状态
	   assertEquals(custServiceEventDO.getCheckStatuz(), CHECK_STATUZ_COMPLETE_CODE);

	    System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDO);

   }

   /***
    * 功能描述:  测试通知作废抽检<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /***
    * 抽检状态为空
    */
   private static  final String SET_CHECK_STATUZ_NULL = "";
   //@Test
   public void testNoteSetAsideCheckRecord(){
	   System.out.println("---------------------测试通知作废抽检方法开始--------------------------");
	   CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   assertNotNull(custServEventVO);
	   Assert.assertNull(custServEventVO.getCheckStatuz());

	   //测试通知作废抽检
	   this.eventManageService.noteSetAsideCheckRecord(custServEventVO.getKeyword());
	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDO);
	   //判断抽检状态是否已改为"已作废"状态
	   assertEquals(custServiceEventDO.getCheckStatuz(), SET_CHECK_STATUZ_NULL);

	    System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDO);

		System.out.println("---------------------测试通知作废抽检方法 END--------------------------");
   }

   /***
    * 功能描述: 测试因为发生作废回访登记,重置事件状态 <br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /***
    * 设置阅签状态为""
    */
//   private static final String SET_REVIEWER_STATUZ_NULL="";
//
//   //@Test
//   public void testResetRV1RStatuzBySetAsideRVisit(){
//
//	   System.out.println("---------------------测试因为发生作废回访登记,重置事件状态方法开始--------------------------");
//
//	   CustServiceEventVO custServEventVO = new CustServiceEventVO();
//	   this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
//	   assertNotNull(custServEventVO);
//
//
//	   //修改事件状态，把事件状态修改"已完成"
//	   custServEventVO.setEventStatuz(EVENT_STATUS_COMPLETE_CODE);
//	   //更新修改后的信息
//	   this.eventManageService.editCustEvent(custServEventVO);
//	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
//	   //判断修改是否成功
//	   //事件状态为已完成
//	   assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_COMPLETE_CODE);
//
//	   //测试因为发生作废回访登记,重置事件状态
//	   //this.eventManageService.resetRV1RStatuzBySetAsideRVisit(custServiceEventDO.getKeyword());
//	   //custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
//	   //assertNotNull(custServiceEventDO);
//
//	   //	 判断回访状态是否变更为"待回访"，阅签状态是否变更为"";
//	   //assertEquals(custServiceEventDO.getReturnVisitStatuz(),RETURN_VISIT_STATUZ_PREPARE_CODE);
//	   //assertEquals(custServiceEventDO.getReviewerStatuz(), SET_REVIEWER_STATUZ_NULL);
//
//
//	    System.out.println("-----------------开始删除客服事件记录-----------------");
//		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
//		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
//		System.out.println("-----------------删除成功-----------------");
//		Assert.assertNull(custServiceEventDO);
//
//		System.out.println("---------------------测试因为发生作废回访登记,重置事件状态方法结束--------------------------");
//
//   }

   /***
    * 功能描述: 测试判断是否可以进行抽检 <br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testIsAllowCheck(){
	   	System.out.println("---------------------测试判断是否可以进行抽检方法开始--------------------------");

	   	CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   	this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   	assertNotNull(custServEventVO);


	   //修改回访状态为"已回访"状态
	   	custServEventVO.setReturnVisitStatuz(RETURN_VISIT_STATUZ_COMPLETE_CODE);
	   //更新修改后的信息
	   	this.eventManageService.editCustEvent(custServEventVO);
	   	CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());

	   //判断回访状态是否为已已回访状态
	   	assertEquals(custServiceEventDO.getReturnVisitStatuz(), RETURN_VISIT_STATUZ_COMPLETE_CODE);

	   //测试判断是否可以进行抽检
	   	System.out.println("测试判断是否可以进行抽检");

	   	boolean isAllowcheck = this.eventManageService.isAllowCheck(custServiceEventDO.getKeyword());
	   	Assert.assertTrue(isAllowcheck);

	    System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDO);
   }

   /***
    * 功能描述: 测试判断是否可以进行回访 <br>
    * Create author:高嵩 <br>
    * Create on:2008-12-26  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   public void testIsAllowReturnVisit(){

   }


   /***
    * 功能描述: 测试关联事件 <br>
    * @roseuid 49251EBF02DE
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testAssociateCSEvent(){
	   //新建主关联事件，产生主事件keyword
		CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   	this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   	assertNotNull(custServEventVO);

	   	List<Long> associatedCSEventList = new ArrayList<Long>();

	   	//模拟5个关联事件
	   for (int i = 0; i < 5; i++) {
		   CustServiceEventVO associatedcustServEventVO = new CustServiceEventVO();
		   	this.eventManageService.addCustEvent(this.getCustServiceEventVO(associatedcustServEventVO));
		   	assertNotNull(associatedcustServEventVO);
		   	associatedCSEventList.add(associatedcustServEventVO.getKeyword());
		   	assertNotNull(associatedCSEventList);
	   }

	   this.eventManageService.associateCSEvent(custServEventVO.getKeyword(), associatedCSEventList);
	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDO);

	   //测试是否是增加关系数目为5次
	   assertEquals(custServiceEventDO.getRelationship(), new Short("5"));

	   //测试关联表关系数目，与主事件相关联，应该关系数目为1
//	   for(Iterator<CustServiceEventDO> iterator = custServiceEventDO.getAssociateEventSet().iterator(); iterator.hasNext();){
//			CustServiceEventDO cdo = iterator.next();
//			assertEquals(cdo.getRelationship(), new Short("1"));
//
//		}
//	   //删除关联表数据
//	   for(Iterator<CustServiceEventDO> iterator = custServiceEventDO.getAssociateEventSet().iterator(); iterator.hasNext();){
//			CustServiceEventDO cdo = iterator.next();
////			删除记录
//			this.custServiceEventDao.deleteObjectById(cdo.getKeyword());
//		}
//	   //custServiceEventDO.getAssociateEventSet()
//
//	   //删除被关联事件表
//	   for(int j=0;j<associatedCSEventList.size();j++){
//		   Long associatedID = associatedCSEventList.get(j);
//		   this.custServiceEventDao.deleteObjectById(associatedID);
//		   Assert.assertNull(this.custServiceEventDao.findById(associatedID).getKeyword());
//	   }
//	   //删除主事件表
//	   this.custServiceEventDao.deleteObjectById(custServiceEventDO.getKeyword());
//	   Assert.assertNull(this.custServiceEventDao.findById(custServiceEventDO.getKeyword()));
   }

   /***
    * 功能描述:  测试解除事件<br>
    * @roseuid 49388F75031C
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testRiddanceCSEvent(){
	   //新建主关联事件，产生主事件keyword
		CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   	this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   	assertNotNull(custServEventVO);

		CustServiceEventVO associatedcustServEventVO = new CustServiceEventVO();
		this.eventManageService.addCustEvent(this.getCustServiceEventVO(associatedcustServEventVO));
		assertNotNull(associatedcustServEventVO);

	   this.eventManageService.riddanceCSEvent(custServEventVO.getKeyword(), associatedcustServEventVO.getKeyword());
	   CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
	   assertNotNull(custServiceEventDO);

	   //测试是否是增加关系数目为5次
	   assertEquals(custServiceEventDO.getRelationship(), new Short("-1"));

   }

   /***
    * 功能描述:  测试通知撤消提交任务<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-29  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   /**
	 * 事件状态:新建
	 */
	public static final String EVENT_STATUS_NEW_CODE = "001";
   //@Test
   public void testCancelSubmitTask(){
	    CustServiceEventVO custServEventVO = new CustServiceEventVO();
	   	this.eventManageService.addCustEvent(this.getCustServiceEventVO(custServEventVO));
	   	assertNotNull(custServEventVO);



	    CustServiceEventDO custServiceEventDO = this.custServiceEventDao.findById(custServEventVO.getKeyword());
		assertNotNull(custServiceEventDO);


		//当事件状态为已完成时,不允许再撤销任务
		//-----------------------------------------------------------------------------------
//		custServiceEventDO.setEventStatuz(EVENT_STATUS_COMPLETE_CODE);
//		this.custServiceEventDao.updateObject(custServiceEventDO);
//		assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_COMPLETE_CODE);
//
//		//测试通知撤消提交任务
//		this.eventManageService.cancelSubmitTask(custServEventVO.getKeyword());
		//Assert.fail("不允许再撤销任务");

		//-----------------------------------------------------------------------------------


//		当事件状态为已提交时,并且保证事件有效性为"有效时"，改变事件状态为"新建"
		//-----------------------------------------------------------------------------------
		custServiceEventDO.setEventStatuz(EVENT_STATUS_SUBMIT_CODE);
		this.custServiceEventDao.updateObject(custServiceEventDO);
		assertEquals(custServiceEventDO.getEventStatuz(), EVENT_STATUS_SUBMIT_CODE);

		//测试通知撤消提交任务
		//this.eventManageService.cancelSubmitTask(custServEventVO.getKeyword());
		//assertEquals(custServEventVO.getEventStatuz(), EVENT_STATUS_NEW_CODE);
		//-----------------------------------------------------------------------------------

		System.out.println("-----------------开始删除客服事件记录-----------------");
		this.custServiceEventDao.doDeleteById(custServiceEventDO.getKeyword());
		custServiceEventDO = this.custServiceEventDao.findById(custServiceEventDO.getKeyword());
		System.out.println("-----------------删除成功-----------------");
		Assert.assertNull(custServiceEventDO);

		System.out.println("---------------------测试通知作废抽检方法 END--------------------------");
   }

   /***
    * 功能描述: 测试查询客服事件列表 <br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testQueryCustServEventList(){

		System.out.println("------------------------查询客服事件列表开始------------------");
		CustServiceEventSearchVO custServiceEventSearchVO = new CustServiceEventSearchVO();
		//事件编号
		custServiceEventSearchVO.setEventNo("SJ20081216001");
//		客户姓名--
		//custServiceEventSearchVO.setOwners("业主A");//支持模湖查询(如:业)
//		房号houseNumber
		//custServiceEventSearchVO.setHouseNumber("1-1A");//支持模湖查询
//		详细地址fullAddress
		//custServiceEventSearchVO.setFullAddress("详细地址1");//支持模湖查询
//		事件性质customerServiceEventNatureDO
		//custServiceEventSearchVO.setCustServEventNatureName(custServEventNatureName)

		List<CustServiceEventVO> list= this.eventManageService.queryCustServEventList(custServiceEventSearchVO);
		assertNotNull(list);
		assertEquals(list.size(),1);
		assertEquals(list.get(0).getEventNo(),"SJ20081216001");
		assertEquals(list.get(0).getFullAddress(),"详细地址1");
		assertEquals(list.get(0).getReturnVisitStatuz(),"001");
		assertEquals(list.get(0).getEventStatuz(),"002");
		Assert.assertNull(list.get(0).getReviewerStatuz());

		for (CustServiceEventVO custServiceEventVO : list) {
			assertEquals(custServiceEventVO.getEventNo(), "SJ20081216001");
			assertEquals(custServiceEventVO.getOwners(), "业主A");
			Assert.assertEquals(custServiceEventVO.getHouseNumber(), "1-1A");
		}

		System.out.println("------------------------查询客服事件列表结束------------------");
   }

   /***
    * 功能描述:  测试按页查询客服事件<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testQueryCustServEventByPage(){

	   System.out.println("------------------------按页查询客服事件开始------------------");
		CustServiceEventSearchVO custServiceEventSearchVO = new CustServiceEventSearchVO();
		//事件编号
		custServiceEventSearchVO.setEventNo("SJ20081216001");
		custServiceEventSearchVO.setPageNo(new Integer(1));
		custServiceEventSearchVO.setPageSize(new Integer(3));
//		客户姓名--
		//custServiceEventSearchVO.setOwners("业主A");//支持模湖查询(如:业)
//		房号houseNumber
		//custServiceEventSearchVO.setHouseNumber("1-1A");//支持模湖查询
//		详细地址fullAddress
		//custServiceEventSearchVO.setFullAddress("详细地址1");//支持模湖查询
//		事件性质customerServiceEventNatureDO
		//custServiceEventSearchVO.setCustServEventNatureName(custServEventNatureName)

		//List<CustServiceEventDO> list= custServiceEventDao.queryCustServEventList(custServiceEventSearchVO);
		Page page= eventManageService.queryCustServEventByPage(custServiceEventSearchVO);
		assertNotNull(page);
		List datas = page.getResult();
		assertEquals(datas.size(),1);//数据集
		assertEquals(page.getResult().size(), 1);//结果集数
		assertEquals(page.getCurrentPageNo(), 1);//当前页
		assertEquals(page.getTotalCount(), 1);//总数
		assertEquals(page.getTotalPageCount(), 1);//总页数
   }

   /***
    * 功能描述:  测试查询关联事件<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testQueryAssociatedCSEventList(){
//	 已测试
	   CustServiceEventSearchVO custServiceEventSearchVO = new CustServiceEventSearchVO();
		custServiceEventSearchVO.setKeyword(new Long(1));
		custServiceEventSearchVO.setPageNo(new Integer(1));
		custServiceEventSearchVO.setPageSize(new Integer(3));

		List<CustServiceEventVO> cvolist = eventManageService.queryAssociatedCSEventList(custServiceEventSearchVO);
		for(CustServiceEventVO cvo : cvolist){
			assertEquals(cvolist.size(), 3);
			assertNotNull(cvo.getEventNo());//事件编号
			//System.out.println(cvo.getEventNo());
			System.out.println(cvo.getContact());
			assertNotNull(cvo.getKeyword());

			assertNotNull(cvo.getFullAddress());//详细地点
			assertNotNull(cvo.getHouseNumber());//房号
			//assertNotNull(cvo.getContact());//联系人
			//assertNotNull(cvo.getEmergencyDegreeName());//紧急程度
			//System.out.println(cvo.getContact()+"   aaaa");

			assertNotNull(cvo.getCustServEventNatureName());//事件性质
			assertNotNull(cvo.getEventContent());//事件内容
			assertNotNull(cvo.getValidityStr());//有效性
			assertNotNull(cvo.getEventStatuzStr());//事件状态
		}
   }

   /***
    * 功能描述:  测试分页查询关联事件<br>
    * Create author:高嵩 <br>
    * Create on:2008-12-23  <br>
    * Edit author:  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
   //@Test
   public void testQueryAssociatedCSEventByPage(){
//	 已测试
	   CustServiceEventSearchVO custServiceEventSearchVO = new CustServiceEventSearchVO();
		custServiceEventSearchVO.setKeyword(new Long(1));
		custServiceEventSearchVO.setPageNo(new Integer(1));
		custServiceEventSearchVO.setPageSize(new Integer(3));
		Page page =eventManageService.queryAssociatedCSEventByPage(custServiceEventSearchVO);
		assertNotNull(page);
		List datas = page.getResult();
		assertEquals(datas.size(),3);
		assertEquals(page.getResult().size(), 3);
		assertEquals(page.getCurrentPageNo(), 1);
		assertEquals(page.getTotalCount(), 3);
		assertEquals(page.getTotalPageCount(), 1);
   }


}
